package com.wnxy.pawnbackgroundsystem.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wnxy.pawnbackgroundsystem.dto.ParameterDto;
import com.wnxy.pawnbackgroundsystem.dto.ParameterPageDto;
import com.wnxy.pawnbackgroundsystem.entity.Parameter;
import com.wnxy.pawnbackgroundsystem.param.AddParameterParam;
import com.wnxy.pawnbackgroundsystem.param.SelectParameterParam;
import com.wnxy.pawnbackgroundsystem.param.UpdateParameterParam;
import com.wnxy.pawnbackgroundsystem.response.Result;
import com.wnxy.pawnbackgroundsystem.service.IParameterService;
import com.wnxy.pawnbackgroundsystem.service.impl.ParameterServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品参数表 前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2021-10-14
 */
@RestController
@RequestMapping("/pawnbackgroundsystem/parameter")
@CrossOrigin("*")
public class ParameterController {
    @Autowired
    private IParameterService parameterService;

    @ApiOperation("商品参数查询")
    @PostMapping("/selectParameter")
    public Result selectParameter(@RequestBody SelectParameterParam spp){
        IPage<ParameterDto> pd=parameterService.selectParameter(spp);
        return new Result(true,"2002","查询成功",pd);
    }

    @ApiOperation("商品参数新增")
    @PostMapping("/add")
    public Result addParameter(@RequestBody AddParameterParam addParameterParam){
        System.out.println(addParameterParam);
        parameterService.addParameter(addParameterParam);
        return new Result(true,"2002","新增成功",null);
    }
    @ApiOperation("商品参数删除")
    @GetMapping("/del")
    public Result delParameter(Integer parameterId){
        parameterService.delParameter(parameterId);
        return new Result(true,"2002","删除成功",null);
    }

    @ApiOperation("商品参数修改")
    @PostMapping("/updateParameter")
    public Result updatePraemeter(@RequestBody UpdateParameterParam updateParameterParam){

        parameterService.updatePraemeter(updateParameterParam);


        return new Result(true,"2002","修改成功",null);
    }


    @ApiOperation("查询参数名称")
    @GetMapping("/getSizeName")
    public Result getSizeName(@RequestParam("parameterId")  Integer parameterId){
        String sizeName=parameterService.getSizeName(parameterId);
        return new Result(true,"2002","查询成功",sizeName);
    }





}

